<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="http://www.baidu.com"></form>
    <input type="submit" value="提交" name="sub">
    <script>

        // 阻止默认行为 让链接不跳转 或者让提交按钮不提交

        var input = document.querySelector('input');

        input.addEventListener('click', function (e) {
            // 1. dom 标准写法
            e.preventDefault();
        });
        input.onclik = function (e) {
            // 3. 只能在传统注册方式中使用
            return false;
        }  
    </script>
</body>

</html>